import { ActionType } from '@ant-design/pro-table';
import { PlusOutlined } from '@ant-design/icons';
import { Button, Form } from 'antd';
import { ModalForm } from '@ant-design/pro-form';
import AppFrom from '../form';
import { addProject } from '@/api';

const FormComponent = ({ action }: { action: ActionType }) => {
  return (
    <ModalForm
      title="新建应用"
      onFinish={async (values) => {
        await addProject({ ...values });
        action.reload();
        return true;
      }}
      onFinishFailed={async (errorInfo) => {}}
      onFieldsChange={(changedFields, allFields) => {}}
      trigger={
        <Button type="primary">
          <PlusOutlined />
          新建应用
        </Button>
      }
      initialValues={{
        rewrite: false,
        type: 'spa',
      }}
    >
      <AppFrom />
    </ModalForm>
  );
};

export default FormComponent;
